package com.mdd.common.util;

import com.mdd.common.enums.order.type.OrderFlowTypeEnum;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author Administrator
 */
public class CodeUtils {

    public static String getFlowNo(OrderFlowTypeEnum orderFlowTypeEnum) {
        // 获取当前时间戳
        long timestamp = System.currentTimeMillis();
        // 获取当前日期
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        String dateStr = dateFormat.format(System.currentTimeMillis());
        // 获取随机数
        Random random = new Random();
        int randomNum = random.nextInt(1000);
        // 组合订单编号
        return   orderFlowTypeEnum.getPrefix() + dateStr + randomNum + timestamp;
    }
}
